The Notification
module in the Scripting app allows you to schedule, manage, and display local notifications with advanced trigger types, interactive actions, and rich UI capabilities.
Use Notification.schedule
to schedule a local notification. It supports text content, triggers, action buttons, custom UI, and delivery configuration:
Name | Type | Description |
---|---|---|
title |
string |
Required. Notification title. |
subtitle |
string? |
Optional. Additional context. |
body |
string? |
Optional. Main content text. |
badge |
number? |
Optional. App icon badge count. |
silent |
boolean? |
Optional. Defaults to true . Set to false to play sound. |
interruptionLevel |
"active" | "passive" | "timeSensitive" |
Optional. Defines priority and delivery behavior. |
userInfo |
Record<string, any>? |
Optional. Custom metadata. |
threadIdentifier |
string? |
Optional. Identifier for grouping notifications. |
trigger |
TimeIntervalNotificationTrigger | CalendarNotificationTrigger | LocationNotificationTrigger | null |
Optional. Defines when the notification is delivered. |
actions |
NotificationAction[]? |
Optional. Action buttons. |
customUI |
boolean? |
Optional. Enables rich notification interface using notification.tsx . |
avoidRunningCurrentScriptWhenTapped |
boolean? |
Optional. Prevents the script from running when tapped. Defaults to false . |
Deprecated:
triggerTime
andrepeatsType
are deprecated. Usetrigger
instead.
Triggers a notification after a specified number of seconds.
timeInterval
: Delay in seconds.repeats
: Whether it repeats.nextTriggerDate()
: Returns the next expected trigger date.Triggers when the current date matches specific calendar components.
year
, month
, day
, hour
, etc.Triggers when entering or exiting a geographic region.
Use the actions
parameter to define buttons shown when a notification is expanded.
Script.createRunURLScheme(scriptName, parameters)
to generate the correct callback URLs.You can provide a JSX-based interface for expanded notifications by:
customUI: true
in Notification.schedule
.notification.tsx
file in your script.Notification.present(element)
inside that file.Notification.present(...)
notification.tsx
.notification.tsx
Method | Description |
---|---|
getAllDelivereds() |
Returns all delivered notifications. |
getAllPendings() |
Returns all scheduled but undelivered notifications. |
removeAllDelivereds() |
Removes all delivered notifications. |
removeAllPendings() |
Cancels all pending notifications. |
removeDelivereds(ids) |
Removes delivered notifications with matching IDs. |
removePendings(ids) |
Cancels scheduled notifications with matching IDs. |
getAllDeliveredsOfCurrentScript() |
Delivered notifications from the current script only. |
getAllPendingsOfCurrentScript() |
Scheduled notifications from the current script only. |
removeAllDeliveredsOfCurrentScript() |
Clears current script’s delivered notifications. |
removeAllPendingsOfCurrentScript() |
Cancels current script’s pending notifications. |
setBadgeCount(count) |
Sets the app icon badge value. |
Use Notification.current
to access information when the script is launched from a notification tap.
NotificationRequest
Field | Description |
---|---|
identifier |
Unique ID for the request |
content.title |
Notification title |
content.subtitle |
Optional subtitle |
content.body |
Notification body |
content.userInfo |
Custom metadata |
content.threadIdentifier |
Grouping key |
trigger |
Trigger object that controls delivery |
This example demonstrates a complete use of notification features: custom UI, interactive actions, time-sensitive interruption level, and repeated delivery using TimeIntervalNotificationTrigger
.
notification.tsx
The Notification
API in the Scripting app provides rich scheduling capabilities, including:
Migrate to the trigger
-based scheduling model for full control and platform-aligned behavior.